/*
	Name: 	init.lua
	Side:	SERVER
	
	Role: 	Serverside entry point for the gamemode.
			All other serverside scripts branch off from here.
			
	NOTES:	Coco: Try and keep just gamemode events in here, everything else put into an included file.
*/

AddCSLuaFile "shared.lua"
AddCSLuaFile "cl_init.lua" 
AddCSLuaFile "client/change_team_gui.lua"

include "shared.lua"
include "server/con_cmds.lua"

--[[---------------------------------------------------------------------------
	Name: gamemode.PlayerConnect
	Desc: Called when a player joins the server
--]]---------------------------------------------------------------------------
function GM:PlayerConnect( name, address )

end

--[[---------------------------------------------------------------------------
	Name: gamemode.PlayerInitialSpawn
	Desc: Called when a player spawns for the first time
--]]---------------------------------------------------------------------------
function GM:PlayerInitialSpawn( ply ) 

	ply:SetTeam( ZS.TEAM_SPECTATOR )
	
end 

--[[---------------------------------------------------------------------------
	Name: gamemode.PlayerSpawn
	Desc: Called whenever a player spawns
--]]---------------------------------------------------------------------------
function GM:PlayerSpawn( ply )
	
	ply:SetMoveType( MOVETYPE_WALK )
	
	if ply:Team() == ZS.TEAM_SPECTATOR then
	
		ply:Spectate( OBS_MODE_ROAMING )
		ply:SetMoveType( MOVETYPE_OBSERVER ) 
		
	end
	
end

--[[---------------------------------------------------------------------------
			DOESN'T WORK
	Name: gamemode.PlayerJoinTeam
	Desc: Called when a player attempts to join a given team
--]]---------------------------------------------------------------------------
function GM:PlayerJoinTeam( ply, teamid )
	
	ply:PrintMessage( HUD_PRINTTALK, "I am joining team '"..team.GetName(teamid).."'" )
	
	if teamid == ZS.TEAM_HUMAN then
		ply:Spawn()
	end
	
	return true
end

--[[---------------------------------------------------------------------------
	Name: gamemode.PlayerLoadout
	Desc: Called when a player needs a loadout, such as after spawning
--]]---------------------------------------------------------------------------
function GM:PlayerLoadout( ply ) 
 
    if ply:Team() == ZS.TEAM_HUMAN then 
 
		ply:Give( "weapon_physgun" )
        ply:Give( "weapon_physcannon" ) 
 
    end 
 
end

--[[---------------------------------------------------------------------------
	Name: gamemode.PlayerDeath
	Desc: Called whenever a player dies
--]]---------------------------------------------------------------------------
function GM:PlayerDeath( ply, inflicter, killer )

end


